// pages/mine/mine.js
//获取应用实例
const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo:{},
    newname:'',
    newimg:'',
    uid:'',
    exchole:{}
  },
  bindViewTap: function () {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
 
  toChange: function () {
    wx.navigateTo({
      url: '../changeMyData/changeMyData',
    })
  },
  toStore: function () {
    wx.navigateTo({
      url: '../store/store',
    })
  },
  toFavorite:function(){
    wx.navigateTo({
      url: '../myFavorite/myFavorite',
    })
  },
  shudong: function () {
    //获取该用户uid
    var that = this;
    wx.getStorage({
      key: 'uid',
      success:function(res){
        that.setData({uid:res.data})
      }
    })
    
    //判断
    wx.getStorage({
      key: 'treedate',
      success:function(res){
       var uidd = res.data.uid
       res.data.map(item=>{
         if(item.uid===that.data.uid){
           that.setData({exchole:item})
           wx.setStorage({
             data: item,
             key: 'exchole',
           })
         }

       })
      }
    })

    wx.navigateTo({
      url: '../goIntoTree/goIntoTree',
    })

  },
  guanzhu: function () {
    wx.navigateTo({
      url: '../myFocus/myFocus',
    })
  },
  xinjian: function () {
    wx.navigateTo({
      url: '../myLetter/myLetter',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
    const app = getApp()
    this.setData({userInfo:app.globalData.userInfo})

    console.log(this.data)
   

   },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    //获取更改后的头像和名字
    wx.getStorage({
      key: 'newimg',
      success:function(res){
        console.log(res)
        that.setData({newimg:res.data})
      }
    })

    wx.getStorage({
      key: 'newname',
      success:function(res){
        that.setData({newname:res.data})
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})